#include "config.h"

My_ADC ADC_Light(ADC1_CHANNEL_0,ADC_WIDTH_BIT_12,ADC_ATTEN_DB_11);



bool Lamp_auto = 0;//1自动0手动

void ADC_Task(void*arg)
{
    static bool up_data = Button1_flag;
    bool Lamp_state = 0; 

    printf("\nADC Task ok!\n");
    while(1)
    {
        ADC_Light.get_voltage();
        printf("Voltage:  %d mV \r\n", ADC_Light.Voltage);
        if(Lamp_auto){
            if(Lamp_state) {
                Button1_flag = 1;
            }
            else if((!Lamp_state) && (rtc.hour > 20)){
                if(ADC_Light.Level == 1){
                    Button1_flag = 1;
                    Lamp_state = 1;
                }
            }
        }
        if(Button1_flag != up_data){
            // heartbeat();
            up_data = Button1_flag;
        }

        vTaskDelay(1000 / portTICK_RATE_MS);
    }
}